package com.sangen.controller;

import com.sangen.domin.ResponseResult;
import com.sangen.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName -> ArticleController
 * @Description
 * @Author User
 * @Date 2023/4/22 11:20 星期六
 * @Version 3.3
 */
@RestController  //使得@Controller + @ResponseBody 的功能可以在页面上展示页面的响应。
@RequestMapping("article")
public class ArticleController {
    @Autowired
    private ArticleService articleService;

//    @GetMapping("/list")
//
//    public List<Article> test(){
//        return articleService.list();
//    }
    @GetMapping("/hotArticleList")
    public ResponseResult hotArticleList(){
        //查询热门文章 封装为ResponseResult返回
        //调用service中的方法查询
        ResponseResult result = articleService.hotArticleList();
        return result;
    }
    @GetMapping("articleList")
    public ResponseResult articleList(Integer pageNum, Integer pageSize,Long categoryId){
        return articleService.articleList(pageNum,pageSize,categoryId);
    }
}